import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    cartItems:JSON.parse(localStorage.getItem('carts')) || []
  },
  mutations: {
    addCart(state){
      state.cartItems = JSON.parse(localStorage.getItem('carts')) || []
    }
  },
  actions: {
    addCart(context){
      context.commit('addCart')
    }
  },
  modules: {
  }
})
